package com.huangpeng.designmodel.enjoyyuan;

import java.util.HashMap;
import java.util.Objects;

/**
 * @Author huangpeng
 * @Title 形状工厂
 * @Package
 * @Date 2020/10/23 15:52
 * @Description 形状工厂
 * @Version 1.0
 */
public class ShapeFactory {
    private static final HashMap<String,Circle> map = new HashMap<>();
    public static Shape getCircle(String color){
        Circle circle = map.get(color);
        if(Objects.isNull(circle)){
            circle = new Circle(color);
            map.put(color,circle);
            System.out.println("Creating circle of color : " + color);
        }
        return circle;
    }
}
